![]() |
Kinetis SDK API Reference Manual
1.0.0-beta
Freescale Semiconductor, Inc.
|
The section describes the programming interface of the DSPI slave mode Peripheral driver. More...
Data Structures | |
| struct | dspi_slave_callbacks_t |
| The set of callbacks for the DSPI slave mode. More... | |
| struct | dspi_slave_state_t |
| Runtime state of the DSPI slave driver. More... | |
| struct | dspi_slave_user_config_t |
| User configuration structure and callback functions for the DSPI slave driver. More... | |
Init and shutdown | |
| dspi_status_t | dspi_slave_init (uint32_t instance, dspi_slave_state_t *dspiState, const dspi_slave_user_config_t *slaveConfig) |
| Initializes a DSPI instance for a slave mode operation. More... | |
| void | dspi_slave_shutdown (dspi_slave_state_t *dspiState) |
| Shut down a DSPI instance. More... | |
| struct dspi_slave_callbacks_t |
The user creates the function implementations.
Data Fields | |
| dspi_status_t(* | dataSource )(uint8_t *sourceWord, uint32_t instance) |
| Callback to get word to transmit. More... | |
| dspi_status_t(* | dataSink )(uint8_t sinkWord, uint32_t instance) |
| Callback to put received word. More... | |
| void(* | onError )(dspi_status_t error, uint32_t instance) |
| Callback to report a DSPI error, such as an under-run or over-run error. More... | |
| dspi_status_t(* dspi_slave_callbacks_t::dataSource)(uint8_t *sourceWord, uint32_t instance) |
| dspi_status_t(* dspi_slave_callbacks_t::dataSink)(uint8_t sinkWord, uint32_t instance) |
| void(* dspi_slave_callbacks_t::onError)(dspi_status_t error, uint32_t instance) |
| struct dspi_slave_state_t |
This struct holds data that is used by the DSPI slave peripheral driver to communicate between the transfer function and the interrupt handler. The user needs to pass in the memory for this structure and the driver fills out the members.
Data Fields | |
| uint32_t | instance |
| DSPI module instance number. | |
| dspi_slave_callbacks_t | callbacks |
| Application/user callbacks. | |
| uint32_t | bitsPerFrame |
| Desired number of bits per frame. | |
| struct dspi_slave_user_config_t |
Data Fields | |
| dspi_slave_callbacks_t | callbacks |
| Application/user callbacks. More... | |
| dspi_data_format_config_t | dataConfig |
| Data format configuration structure. | |
| dspi_slave_callbacks_t dspi_slave_user_config_t::callbacks |
| dspi_status_t dspi_slave_init | ( | uint32_t | instance, |
| dspi_slave_state_t * | dspiState, | ||
| const dspi_slave_user_config_t * | slaveConfig | ||
| ) |
This function saves the callbacks to the run-time state structure for a later use in the interrupt handler. It also ungates the clock to the DSPI module, initializes the DSPI for slave mode, and enables the module and corresponding interrupts. Once initialized, the DSPI module is configured in slave mode and ready to receive data from the SPI master. This is an example to set up the dspi_slave_state_t and the dspi_slave_user_config_t parameters and to call the dspi_slave_init function by passing in these parameters:
| instance | The instance number of the DSPI peripheral. |
| dspiState | The pointer to the DSPI slave driver state structure. |
| user | The configuration structure dspi_slave_user_config_t, including the callbacks. |
| void dspi_slave_shutdown | ( | dspi_slave_state_t * | dspiState | ) |
Resets the DSPI peripheral, disables the interrupt to the core, and gates its clock.
| dspiState | The pointer to the DSPI slave driver state structure. |